package meiyunting.shiwuzhaoling;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableDiscoveryClient  // 启用服务发现
@EnableFeignClients     // 启用Feign客户端
public class ShiwuzhaolingApplication {

    @Value("${server.port}")
    private String serverPort;

    public static void main(String[] args) {
        SpringApplication.run(ShiwuzhaolingApplication.class, args);
    }
    
    @Bean
    public CommandLineRunner printStartupInfo() {
        return args -> {
            System.out.println("\n\n");
            System.out.println("=======================================================");
            System.out.println("    失物招领系统已启动，运行在端口: " + serverPort);
            System.out.println("    访问 http://localhost:" + serverPort + "/api/demo/call-instance");
            System.out.println("    测试负载均衡");
            System.out.println("=======================================================");
            System.out.println("\n\n");
        };
    }
}
